/**
 * @file crc.h
 * @brief
 * @author xuesong (wenshaoliu@foxmail.com)
 * @version 1.0
 * @date 2024-08-21
 *
 * @copyright Copyright (c) 2024  by xuesong
 *
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-08-21     <td>1.0     <td>xuesong   <td>内容
 * </table>
 */
#ifndef __CRC__H__
#define __CRC__H__

#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stddef.h>
#include <string.h>

    //--------------------------------------------------
    void InvertUint8(unsigned char *dBuf, unsigned char *srcBuf);
    void InvertUint16(unsigned short *dBuf, unsigned short *srcBuf);
    void InvertUint32(unsigned int *dBuf, unsigned int *srcBuf);
    unsigned char crc8_seed(unsigned char seed, unsigned char *vptr, unsigned char len);
    unsigned char crc8_high_first(unsigned char seed, unsigned char *ptr, unsigned char len);
    uint16_t HaierCrc16(uint16_t crc, uint8_t const *buffer, uint32_t len);
    uint16_t ModBusCrc16(uint16_t seed, const volatile void *p_data, uint32_t size);
    unsigned short CRC16_ModBus(unsigned char *data, unsigned int datalen);
    uint16_t calcCrc16(uint8_t *data, int32_t offset, int32_t len, uint16_t preval);

#ifdef __cplusplus
}
#endif

#endif
